package com.clgc.eduservice.schedule;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.clgc.eduservice.entity.EduTopic;
import com.clgc.eduservice.service.EduTopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author lsr
 * @create 2021-05-25-13:49
 */
@Component
public class TopicSche {

    @Autowired
    EduTopicService topicService;

    @Cacheable(key = "'choice'", value = "topic")
    public List<EduTopic> getChoice() {//获取单选题
        QueryWrapper<EduTopic> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("kind", "单选题");
        List<EduTopic> list = topicService.list(queryWrapper);
        return list;
    }

    @Cacheable(key = "'multiple'", value = "topic")
    public List<EduTopic> getMultipleNum() {
        QueryWrapper<EduTopic> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("kind", "多选题");
        List<EduTopic> list = topicService.list(queryWrapper);
        return list;
    }

    @Cacheable(key = "'fill'", value = "topic")
    public List<EduTopic> getFillNum() {
        QueryWrapper<EduTopic> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("kind", "填空题");
        List<EduTopic> list = topicService.list(queryWrapper);
        return list;
    }

    @Cacheable(key = "'judgment'", value = "topic")
    public List<EduTopic> getJudgmentNum() {
        QueryWrapper<EduTopic> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("kind", "判断题");
        List<EduTopic> list = topicService.list(queryWrapper);
        return list;
    }

    @Cacheable(key = "'short'", value = "topic")
    public List<EduTopic> getShortNum() {
        QueryWrapper<EduTopic> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("kind", "简答题");
        List<EduTopic> list = topicService.list(queryWrapper);
        return list;
    }

}
